﻿@using KPIS.GERP.Models.SYS.ViewModel
@using KPIS.GERP.WEB.GFMS.Class
@model IEnumerable<MenuItem>

@{
	var mod = (Model ?? new List<MenuItem>()).Where(o => GimsMembership.IsInRoles(o.Roles));
}
		@{
			//KPIS.GERP.Logging.GerpLog.Error("asdf#8", null);
			//Convert.ToInt32("#)");
			//KPIS.GERP.Logging.GerpLog.Error("asdf#9", null);
		}
<!--start_Menu-->
    <div id="sidebar" >
        <!--sidebar-shortcuts-->
        @Html.Partial("_SideBarShortcut")
		@* @Html.Menu(MenuHelper.MenuItems) *@
		
		@if(Model != null)
		{
			<ul class="nav nav-list">
	   
				@foreach (var stItem in mod)
				{
					bool insideSubItem;
					bool isSameController = Html.IsSameControllerAndAction(stItem, out insideSubItem);
					string className = isSameController || insideSubItem ? " active " : string.Empty;
					className += insideSubItem ? " open " : string.Empty;
					string activeString = isSameController || insideSubItem ? string.Format(" class='{0}'", className) : string.Empty;
		
					if (stItem.MenuItems == null || stItem.MenuItems.Count == 0)
					{
						<li @Html.Raw(activeString)><a href="@Url.Content(stItem.NavigateUrl)"><i class="@stItem.Icon"></i><span>@stItem.Text</span></a></li>
					}
					else
					{
						<li @Html.Raw(activeString)><a href="#" class="dropdown-toggle"><i class="@stItem.Icon"></i><span>@stItem.Text</span><b class="arrow icon-angle-down"></b></a>
							<ul class="submenu">
								@foreach (var ndItem in stItem.MenuItems)
								{
									bool isThisSubIsSameController = Html.IsSameController(ndItem, out insideSubItem) && ndItem.NavigateUrl != "#";
									var classNameInSub = string.Empty;
									if (isThisSubIsSameController)
									{
										classNameInSub = " class=active";
									}
									<li @classNameInSub><a href="@Url.Content(ndItem.NavigateUrl)"><i class="icon-double-angle-right"></i>@ndItem.Text</a></li>
								}
							</ul>
						</li>
					}
				}
			</ul>
	  
			<!--collape-buttton-->
			<div id="sidebar-collapse">
				<i class="icon-double-angle-left"></i>
			</div>
		}
	</div ><!--/.end-menu-->